from websocket_information import DevicesImpl, TypeImpl, ConnectionImpl, GroupImpl, ParamsImpl


def default():
    print('No such case')


# 设备
def get_devices(uuid, message):
    DevicesImpl.get_devices(ws, uuid)


def get_device_by_id(uuid, message):
    DevicesImpl.get_device_by_id(ws, uuid, message)


def add_device(uuid, message):
    DevicesImpl.add_device(ws, uuid, message)


def update_device(uuid, message):
    DevicesImpl.update_device(ws, uuid, message)


def delete_device(uuid, message):
    DevicesImpl.delete_device(ws, uuid, message)


def status_equipment(uuid, message):
    DevicesImpl.status_equipment(ws, uuid, message)


# 类型
def get_types(uuid, message):
    TypeImpl.get_types(ws, uuid)


def get_type_by_id(uuid, message):
    TypeImpl.get_type_by_id(ws, uuid, message)


def add_type(uuid, message):
    TypeImpl.add_type(ws, uuid, message)


def update_type(uuid, message):
    TypeImpl.update_type(ws, uuid, message)


def delete_type(uuid, message):
    TypeImpl.delete_type(ws, uuid, message)


# 关系
def get_connections(uuid, message):
    ConnectionImpl.get_connections(ws, uuid)


def get_connection_by_id(uuid, message):
    ConnectionImpl.get_connection_by_id(ws, uuid, message)


def add_connection(uuid, message):
    ConnectionImpl.add_connection(ws, uuid, message)


def update_connection(uuid, message):
    ConnectionImpl.update_connection(ws, uuid, message)


def delete_connection(uuid, message):
    ConnectionImpl.delete_connection(ws, uuid, message)


def get_relational_brain_map(uuid, message):
    ConnectionImpl.get_relational_brain_map(ws, uuid)


# 分组
def get_groups(uuid, message):
    GroupImpl.get_groups(ws, uuid)


def get_group_by_id(uuid, message):
    GroupImpl.get_group_by_id(ws, uuid, message)


def add_group(uuid, message):
    GroupImpl.add_group(ws, uuid, message)


def update_group(uuid, message):
    GroupImpl.update_group(ws, uuid, message)


def delete_group(uuid, message):
    GroupImpl.delete_group(ws, uuid, message)


def get_param_names(uuid, message):
    ParamsImpl.get_param_names(ws, uuid, message)


def modify_params(uuid, message):
    ParamsImpl.modify_params(ws, uuid, message)


def get_logs(uuid, message):
    ConnectionImpl.get_logs(ws, uuid, message)


switch = {
    'getDevices': get_devices,
    'getDeviceById': get_device_by_id,
    'addDevice': add_device,
    'updateDevice': update_device,
    'deleteDevice': delete_device,
    'statusEquipment': status_equipment,

    'getTypes': get_types,
    'getTypeById': get_type_by_id,
    'addType': add_type,
    'updateType': update_type,
    'deleteType': delete_type,

    'getConnections': get_connections,
    'getConnectionById': get_connection_by_id,
    'addConnection': add_connection,
    'updateConnection': update_connection,
    'deleteConnection': delete_connection,
    'getRelationalBrainMap': get_relational_brain_map,

    'getGroups': get_groups,
    'getGroupById': get_group_by_id,
    'addGroup': add_group,
    'updateGroup': update_group,
    'deleteGroup': delete_group,

    'getParamNames': get_param_names,
    'modifyParams': modify_params,

    'getLogs': get_logs

}

global ws


def instruction_impl(code, uuid, message, webs):
    global ws
    ws = webs
    switch.get(code, default)(uuid, message)
